package com.abp.controller;

import com.abp.entity.BookRanking;
import com.abp.service.RankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "http://localhost:63342")  // 允许特定来源跨域请求
@RestController
@RequestMapping("/api/ranking")
public class RankingController {

    @Autowired
    private RankingService rankingService;

    // 根据用户ID获取该用户的图书喜好排名
    @GetMapping("/{userId}")
    public List<BookRanking> getBookRanking(@PathVariable int userId) {
        return rankingService.getBookRankingByUserId(userId);
    }
}
